{extend name="admin@index_layout"/}
{block name="main"}
<link rel="stylesheet" href="__STATIC__/admin/css/cms.css">
<div class="layui-card">
	<div class="layui-card-body layui-form-pane">
		<form class="layui-form form-horizontal" action="" method="post" lay-filter="example">
			<div class="layui-form-item">
				<label class="layui-form-label">站点名称</label>
				<div class="layui-input-block">
					<input type="text" name="name" lay-verify="required" lay-reqtext="站点名称不能为空" autocomplete="off" placeholder="" class="layui-input" value="{$data.name|default=''}">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">语言标识</label>
				<div class="layui-input-inline">
					<input autocomplete="off" class="layui-input" id="mark" name="mark" placeholder="语言标识" type="text" value="{$data.mark|default=''}">
				</div>
				<div class="layui-input-inline">
					<select lay-filter="fasttype">
						<option data-mark="zh-cn">常用语言标识</option>
						{volist name="languages" id="vo"}
						<option data-mark="{$vo.mark}"  {eq name="vo.mark" value="$data.mark|default=''" }selected{/eq}>{$vo.name}</option>
						{/volist}
					</select>
				</div>
				<div class="layui-form-mid layui-word-aux">
					多语言选相应的语言就行，如果站群，选相应的语言就行
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">绑定域名</label>
				<div class="layui-input-inline">
					<select name="http" lay-verify="required">
						<option value=""></option>
						<option value="https" {if $data['http']='https'}selected{/if}>https://</option>
						<option value="http" {if $data['http']='http'}selected{/if}>http://</option>
					</select>
				</div>
				<div class="layui-input-inline">
					<input type="text" name="domain" lay-verify="required" lay-reqtext="站点域名不能为空" autocomplete="off" placeholder="en.dzdcms.com" class="layui-input" value="{$data.domain|default=''}">
				</div>
				<div class="layui-form-mid layui-word-aux">
					域名只支持二级域名或顶级域名，不可有子目录
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">上级站点</label>
				<div class="layui-input-block">
					<select name="parentid">
						<option value="0">作为顶级站点</option>
						{$site|raw}
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">品牌名称</label>
				<div class="layui-input-block">
					<input type="text" name="brand" autocomplete="off" placeholder="" class="layui-input" value="{$data.brand|default=''}">
				</div>
				<div class="layui-form-mid layui-word-aux">如:多站点</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">SEO标题</label>
				<div class="layui-input-block">
					<input type="text" name="title" autocomplete="off" placeholder="" class="layui-input" value="{$data.title|default=''}">
				</div>
				<div class="layui-form-mid layui-word-aux">网页的title值</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">SEO关键词</label>
				<div class="layui-input-block">
					<input type="text" name="keywords" autocomplete="off" placeholder="" class="layui-input" value="{$data.keywords|default=''}">
				</div>
				<div class="layui-form-mid layui-word-aux">网页的keywords值</div>
			</div>
			<div class="layui-form-item web_seo">
				<label class="layui-form-label">SEO描述</label>
				<div class="layui-input-block">
					<textarea name="description" placeholder="网站简介" class="layui-textarea">{$data.description|default=''}</textarea>
				</div>
				<div class="layui-form-mid layui-word-aux">网页的description值</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">网站Logo</label>
				<div class="layui-input-block layui-upload">
					{php}echo \util\Form::images('logo','',$data['logo']){/php}
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">网站图标</label>
				<div class="layui-input-block layui-upload">
					{php}echo \util\Form::images('favicon','',$data['favicon']){/php}
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">主题风格</label>
				<div class="layui-input-block">
					<select name="template" lay-verify="required" lay-reqtext="请选择站点主题风格！">
						<option value="">请选择主题风格</option>
						{volist name="templates" id="vo"}
						<option value="{$vo.name}" {eq name="vo.name" value="$data.template|default=''" }selected{/eq}>{$vo.name}</option>
						{/volist}
					</select>
				</div>
				<div class="layui-form-mid layui-word-aux">模版请先上传到template下面并包含info.ini文件</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">站点排序</label>
				<div class="layui-input-block">
					<input type="number" name="listorder" autocomplete="off" placeholder="排序" class="layui-input" value="{$data.listorder|default='0'}">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">独立数据</label>
				<div class="layui-input-block">
					<input type="radio" name="alone" value="1" {if !$data['alone']}checked{/if} {eq name="data.alone" value="1" }checked{/eq} title="是">
					<input type="radio" name="alone" value="0" {eq name="data.alone" value="0" }checked{/eq} title="否">
				</div>
				<div class="layui-form-mid layui-word-aux">选否时：主要实用于城市分站、自动调用主站数据并在相应位置自动添加区域名称（站点名称）！</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">是否显示</label>
				<div class="layui-input-block">
					<input type="radio" name="status" value="1" {if !$data['status']}checked{/if} {eq name="data.status" value="1" }checked{/eq} title="是">
					<input type="radio" name="status" value="0" {eq name="data.status" value="0" }checked{/eq} title="否">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">站点开关</label>
				<div class="layui-input-block">
					<input type="radio" name="close" value="1" {if !$data['close']}checked{/if} {eq name="data.close" value="1" }checked{/eq} title="开">
					<input type="radio" name="close" value="0" {eq name="data.close" value="0" }checked{/eq} title="关">

				</div>
			</div>
			<input name="id" type="hidden" value="{$data.id}">
			<div class="layui-form-item layer-footer">
				<div class="layui-input-block">
					{if $push}
					<button class="layui-btn layui-btn-danger btn-import iconfont icon-dibu site-translator" type="button" title="一键翻译主站数据！">翻译</button>
					{/if}
					<button class="layui-btn" lay-submit>立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
	layui.use(['form','yznForm'], function() {
		var yznForm = layui.yznForm;
		var form = layui.form;
		yznForm.listen();

		form.on('select(fasttype)', function(data) {
			$('#mark').val($(data.elem).find("option:selected").attr("data-mark"));
		});

		$('.site-translator').click(function(){
			// var mark =
			$.ajax({
				type: "POST",
				url: "{:url('translator')}",
				data: {mark:$("#mark").val()},
				dataType: "json",
				success: function(data){
					if (data.code){
						//表单赋值
						form.val('example', {
							"title": data.data.title
							,"keywords": data.data.keywords
							,"description": data.data.description
						});
					}else{
						layer.msg(data.msg);
					}
				}
			})
		})
	});
</script>
{/block}